Name "pyLastPlayer"
OutFile "pyLastPlayer-installer.exe"
InstallDir $PROGRAMFILES\pyLastPlayer
InstallDirRegKey HKLM "Software\NSIS_pyLastPlayer" "Install_Dir"
RequestExecutionLevel admin

;--------------------------------

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

Section "pyLastPlayer (required)"

  SectionIn RO
  SetOutPath $INSTDIR
  File "build\exe.win32-3.2\*"
  SetOutPath "$INSTDIR\phonon_backend"
  File "build\exe.win32-3.2\phonon_backend\*"
  SetOutPath "$INSTDIR\imageformats"
  File "build\exe.win32-3.2\imageformats\*"
  
  WriteRegStr HKLM SOFTWARE\NSIS_pyLastPlayer "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pyLastPlayer" "DisplayName" "pyLastPlayer"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pyLastPlayer" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pyLastPlayer" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pyLastPlayer" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
  
SectionEnd

Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\pyLastPlayer"
  CreateShortCut "$SMPROGRAMS\pyLastPlayer\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\pyLastPlayer\pyLastPlayer.lnk" "$INSTDIR\pyLastPlayer.exe" "" "$INSTDIR\pyLastPlayer.exe" 0
  
SectionEnd

Section "Uninstall"
  
  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pyLastPlayer"
  DeleteRegKey HKLM SOFTWARE\NSIS_pyLastPlayer

  ; Remove files and uninstaller
  Delete "$INSTDIR\phonon_backend\*"
  RMDir  "$INSTDIR\phonon_backend"
  Delete "$INSTDIR\imageformats\*"
  RMDir  "$INSTDIR\imageformats"
  Delete "$INSTDIR\*"

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\pyLastPlayer\*.*"

  ; Remove directories used
  RMDir "$SMPROGRAMS\pyLastPlayer"
  RMDir "$INSTDIR"

SectionEnd
